﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;
namespace SIMSProject.Common
{
    class PermissionHelper
    {
        public static bool CheckCurrentUserHasRole(string roleName)
        {
            SPRoleDefinitionBindingCollection userRoles = SPContext.Current.Web.AllRolesForCurrentUser;
            SPRoleDefinitionCollection roleDefinitions = SPContext.Current.Web.RoleDefinitions;
            SPRoleDefinition roleDefinition = roleDefinitions[roleName];
            if (userRoles.Contains(roleDefinition))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
